package net.app.zoneland.platform.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.app.zoneland.domain.SysRoleResource;
import net.app.zoneland.dto.RourcesDTO;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;
import java.util.List;

/**
 * @Description
 * @Author LENOVO
 * @CreateTime 2020/12/20 17:33
 * @Version: 1.0
 */
@Mapper
public interface SysRoleResourceMapper extends BaseMapper<SysRoleResource> {

    @Select("<script>" +
            "   select role_id from sys_role_resource where resource_id=#{resourceId} " +
            "</script>")
    List<Integer> listByResourceId(Integer resourceId);

    @Select("<script>" +
            "    select r.resource_id,s.`name` from sys_role_resource r JOIN sys_resource s where r.resource_id=s.id and r.role_id=#{roleId} " +
            "</script>")
    List<RourcesDTO> findRourceById(Integer roleId);

}
